' Draw three circles in the same row SCREEN 12 COLOR 4 ' LET ROW = 200 LET RADIUS = 20 ' LET COLUMN = 50 CIRCLE (COLUMN, ROW),RADIUS ' LET COLUMN = 100 CIRCLE (COLUMN, ROW),RADIUS ' LET COLUMN = 150 CIRCLE (COLUMN, ROW),RADIUS ' ENDA simple change in one statement is all that it takes.
INPUT
with Graphics
The above program can easily be modified by changing
the value that the LET statement puts in ROW.
An INPUT
statement is a way for the user of a program
to enter a value while the program is running.
Here is a modified program that asks the user to type
in a value for ROW:
' Draw three circles in the same row ' Ask the user for the row to use PRINT "What row do you want" 'statement 1 INPUT ROW 'statement 2 ' SCREEN 12 'statement 3 COLOR 4 'statement 4 LET RADIUS = 20 'statement 5 ' LET COLUMN = 50 'statement 6 CIRCLE (COLUMN, ROW), RADIUS 'statement 7 ' LET COLUMN = 100 'statement 8 CIRCLE (COLUMN, ROW), RADIUS 'statement 9 ' LET COLUMN = 150 'statement 10 CIRCLE (COLUMN, ROW), RADIUS 'statement 11 ' END 'statement 12(If you type this program in and run it, you don't have to type in the comments "statement 1" and so on.) This program is more complicated than most you have seen. Statements execute (are done) one-by-one starting with the first. Here is what it does, step by step:
INPUT
statement puts a "? " on the ordinary screen
and waits for the user to type a number. Say that the
user typed 99. The statement will put 99 in the part
of memory called ROW.SCREEN
statement (statement 3) sends electronic signals to the
graphics hardware so that graphics screen 12 will work.COLOR
statement selects color 4 (red) for the pen.CIRCLE
statement has no numbers in it—so it must
look into the variables COLUMN, ROW, and RADIUS for the
numbers it needs. It finds 50, 99, and 20; and so draws
a red circle at (x=50, y=99) with radius 20.CIRCLE
statement must
look into the variables COLUMN, ROW, and RADIUS for the
numbers it needs. It finds 100, 99, and 20; and so draws
a red circle at (x=100, y=99) with radius 20.CIRCLE
statement must
look into the variables COLUMN, ROW, and RADIUS for the
numbers it needs. It finds 150, 99, and 20; and so draws
a red circle at (x=150, y=99) with radius 20.
Of course you have several INPUT
statements
preceding the SCREEN
to get several numbers
from the user.
How could you modify the above program so that it also asked the user for the color number of the circles?